<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // const 具有块级作用域  值不可更改
        if (true) {
            const a = 10;
            if (true) {
                const a = 20;
                console.log(a);
            }
            console.log(a);
        }
        // console.log(a);
        const pi = 3.14;
        pi = 3.14;
        //console.log(pi);//Assignment to constant variable. 不让赋值

        const arr = ['a', 'b'];
        arr[0] = '1';
        arr[1] = '2'; //可以赋值
        arr = ['1', '2']; //错误Assignment to constant variable. 不让赋值
    </script>
</body>

</html>